/*
 * Created by JFormDesigner on Tue May 28 18:40:14 HKT 2024
 */

package view.user;



import model.user.User;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout;

/**
 * @author 11565
 */
public class EditPanel extends JPanel {
    private Mainframe frame;
    private User user;
    public EditPanel(Mainframe frame, User user) {
        initComponents();
        this.frame = frame;
        this.user = user;
    }

    private void Confrim(ActionEvent e) {
        // TODO add your code here
        user.setName(NameField.getText());
        user.setIDNumber(IDField.getText());
        user.setContactInformation(PhoneField.getText());
        user.setPassword(PasswordField.getText());
        JOptionPane.showMessageDialog(null, "修改成功");
        //跳转界面
        frame.showUserInfoPanel();
    }

    private void Back(ActionEvent e) {
        // TODO add your code here
        frame.showUserInfoPanel();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - 马世鹏
        panel1 = new JPanel();
        panel2 = new JPanel();
        label1 = new JLabel();
        NameField = new JTextField();
        label2 = new JLabel();
        label3 = new JLabel();
        label4 = new JLabel();
        IDField = new JTextField();
        PhoneField = new JTextField();
        PasswordField = new JTextField();
        ConfrimButton = new JButton();
        BackButton = new JButton();

        //======== this ========
        setBorder (new javax. swing. border. CompoundBorder( new javax .swing .border .TitledBorder (new javax. swing. border
        . EmptyBorder( 0, 0, 0, 0) , "JF\u006frmDes\u0069gner \u0045valua\u0074ion", javax. swing. border. TitledBorder. CENTER, javax
        . swing. border. TitledBorder. BOTTOM, new java .awt .Font ("D\u0069alog" ,java .awt .Font .BOLD ,
        12 ), java. awt. Color. red) , getBorder( )) );  addPropertyChangeListener (new java. beans
        . PropertyChangeListener( ){ @Override public void propertyChange (java .beans .PropertyChangeEvent e) {if ("\u0062order" .equals (e .
        getPropertyName () )) throw new RuntimeException( ); }} );

        //======== panel1 ========
        {
            panel1.setLayout(new CardLayout());

            //======== panel2 ========
            {

                //---- label1 ----
                label1.setText("\u59d3\u540d\uff1a");

                //---- label2 ----
                label2.setText("\u8eab\u4efd\u8bc1\u53f7\uff1a");

                //---- label3 ----
                label3.setText("\u7535\u8bdd\u53f7\u7801\uff1a");

                //---- label4 ----
                label4.setText("\u5bc6\u7801\uff1a");

                //---- ConfrimButton ----
                ConfrimButton.setText("\u786e\u8ba4\u4fee\u6539");
                ConfrimButton.addActionListener(e -> Confrim(e));

                //---- BackButton ----
                BackButton.setText("\u53d6\u6d88\u4fee\u6539");
                BackButton.addActionListener(e -> Back(e));

                GroupLayout panel2Layout = new GroupLayout(panel2);
                panel2.setLayout(panel2Layout);
                panel2Layout.setHorizontalGroup(
                    panel2Layout.createParallelGroup()
                        .addGroup(panel2Layout.createSequentialGroup()
                            .addGap(149, 149, 149)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addGroup(panel2Layout.createSequentialGroup()
                                    .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                        .addComponent(label1)
                                        .addComponent(label3)
                                        .addComponent(label2)
                                        .addComponent(label4))
                                    .addGap(18, 18, 18)
                                    .addGroup(panel2Layout.createParallelGroup()
                                        .addComponent(PhoneField, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(PasswordField, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(IDField, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(NameField, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE)))
                                .addGroup(panel2Layout.createSequentialGroup()
                                    .addGap(26, 26, 26)
                                    .addComponent(BackButton)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(ConfrimButton)))
                            .addContainerGap(150, Short.MAX_VALUE))
                );
                panel2Layout.setVerticalGroup(
                    panel2Layout.createParallelGroup()
                        .addGroup(panel2Layout.createSequentialGroup()
                            .addGap(69, 69, 69)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label1)
                                .addComponent(NameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label2)
                                .addComponent(IDField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(panel2Layout.createParallelGroup()
                                .addComponent(label3)
                                .addComponent(PhoneField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label4)
                                .addComponent(PasswordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGap(27, 27, 27)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(BackButton)
                                .addComponent(ConfrimButton))
                            .addContainerGap(53, Short.MAX_VALUE))
                );
            }
            panel1.add(panel2, "card1");
        }

        GroupLayout layout = new GroupLayout(this);
        setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
        );
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - 马世鹏
    private JPanel panel1;
    private JPanel panel2;
    private JLabel label1;
    private JTextField NameField;
    private JLabel label2;
    private JLabel label3;
    private JLabel label4;
    private JTextField IDField;
    private JTextField PhoneField;
    private JTextField PasswordField;
    private JButton ConfrimButton;
    private JButton BackButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
